package com.examples.ry.layouts;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * Despite the fact that RowLayout can be used to create multiple rows or
 * columns, when wrap is set to true, the intent is for RowLayout to position
 * controls in a single row or column. To position controls in multiple rows,
 * GridLayout can be used.
 * 
 * @author ryada9
 * 
 */

public class RowLayout1 {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		RowLayout layout = new RowLayout(SWT.VERTICAL);
		layout.spacing = 0; // Default value is 3
		/*
		 * Q. Wts the diff between marginHeight and marginTop?? A. marginHeight
		 * will leave equal margin from top and bottom both, where as marginTop
		 * will leave margin only on top.
		 */

		layout.marginTop = 20; // default is 3
		layout.marginHeight = 10; // Default is 0

		layout.marginWidth = 10;
		layout.marginLeft = 10;
		layout.marginRight = 30;
		layout.pack = false; // Default is true
		layout.justify = true; // Default is false
		layout.wrap = false; // Default is true

		shell.setLayout(layout);
		for (int i = 0; i < 12; i++) {
			Button button = new Button(shell, SWT.PUSH);
			String text = "B";
			for(int j=0;j<=5;j++){
				text += text+1;
			}
			button.setText(text);
		}
		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

}
